import { createElement, HTMLAttributes, type FC } from 'react';
import classNames from 'classnames';

import { messageContentDefaultProps } from './defaultProps';
import type { MessageContentOptions } from './type';

export interface MessageContentProps extends MessageContentOptions, HTMLAttributes<HTMLDivElement> {}

const MessageContent: FC<MessageContentProps> = (props) => {
  const { className, children, forwardedRef, ...messageContentProps } = props;

  return createElement(
    'div',
    { ref: forwardedRef, className: classNames('content', className), ...messageContentProps },
    children,
  );
};

MessageContent.displayName = 'MessageContent';
MessageContent.defaultProps = messageContentDefaultProps;

export default MessageContent;
